package droid.frame.utils.android;

import droid.frame.utils.Android;
import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;

/**
 * 输入法工具类 <br>see{@link Android}
 * 
 * @author coffee
 */
@Deprecated
public class ImmUtils {
	private static InputMethodManager imm;

	// 显示输入法
	public static void show(Context context, View focusView) {
		imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
		imm.showSoftInput(focusView, InputMethodManager.SHOW_FORCED);
	}

	// 隐藏输入发
	public static void hide(Context context) {
		View view = ((Activity) context).getWindow().peekDecorView();
		if (view != null && view.getWindowToken() != null) {
			imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
			imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
		}
	}

	// 调用该方法；键盘若显示则隐藏; 隐藏则显示
	public static void toggle(Context context) {
		imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
		imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
	}

}
